package ee.ut.maxorato_macobo.oop.mudclient;

import ee.ut.maxorato_macobo.oop.mudclient.network.ClientIoManager;
import ee.ut.maxorato_macobo.oop.mudclient.ui.ClientWindow;

public class ClientMain {
	private static ClientWindow mainWindow = null;
	
	public static void main(String[] args) {
		mainWindow = new ClientWindow("Mud client");
		
		ClientIoManager.initNetty();
		ClientIoManager.connectNetty("maxorator.com", 4003);
	}
	
	public static ClientWindow getMainWindow() {
		return mainWindow;
	}
	
	public static void changeConnection(boolean newStatus) {
		if (newStatus != ClientIoManager.getIsConnected()) {
			if (newStatus)
				ClientIoManager.connectNetty("maxorator.com", 4003);
			else
				ClientIoManager.disconnectNetty();
			setConnection(newStatus);
		}
	}
	
	public static void setConnection(boolean connected) {
		mainWindow.setConnected(connected);
	}
}
